package com.hardson.toolkit.swing.table;

import java.awt.Component;

import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;

class GroupRenderer extends DefaultTableCellRenderer {
	private static final long serialVersionUID = 1L;

	@Override
	public Component getTableCellRendererComponent(final JTable table, final Object value,
			final boolean isSelected, final boolean hasFocus, final int row, final int column) {
		JTableHeader header = table.getTableHeader();
		if (header != null) {
			this.setForeground(header.getForeground());
			this.setBackground(header.getBackground());
			this.setFont(header.getFont());
		}
		this.setHorizontalAlignment(SwingConstants.CENTER);
		this.setText((value == null) ? "" : value.toString());
		this.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
		return this;
	}

}
